import Cookies from 'js-cookie'
import {sm2} from "sm-crypto";
import cache from '@/plugins/cache'

const TokenKey = 'Mo-Token'

export function getToken() {
  return cache.local.get(TokenKey)
  // return Cookies.get(TokenKey)
}

export function setToken(token) {
  return cache.local.set(TokenKey, token)
  // return Cookies.set(TokenKey, token)
}

export function removeToken() {
  cache.local.remove(TokenKey)
  // return Cookies.remove(TokenKey)
}

const PublicKeyStr = '04d19658c3b0c0fcaea98c1b66d3abf21f8f171d787cea980bfa177915d954508d2082a3d29374aa511f73331790083979d75b447ca88978a0339556b016b45cf3'
const cipherMode = 1 //1-c1c3c2, 0-c1c2c3,
export function encryptPassword(str) {
  return sm2.doEncrypt(str, PublicKeyStr, cipherMode)
}
